A memory device comprises a controller and a nonvolatile memory controlled by the controller. The nonvolatile memory has, for example, a plurality of blocks. Moreover, a data erase operation is executed by the block. A block is identified as a bad block when a count of fail bits, which are included in the block and are failed to be erased even after the erase operation has terminated, exceeds a specified value. Once a block is identified as a bad block, then such a block is no longer used for data writing operation. The count of fail bits generally increases as the erase count (the erase frequency) increases. Therefore, the controller causes an erase operation to be equally executed at a plurality of blocks so as to control wear leveling.